home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Icon / c / SetDouble < prev    next >
Text File  |  1995-07-08  |  794b  |  27 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include "DeskLib:Wimp.h"
  5. #include "DeskLib:WimpSWIs.h"
  6. #include "DeskLib:Icon.h"
  7.  
  8.  
  9. extern void Icon_SetDouble(window_handle w, icon_handle i,
  10.                            double value, int decimalplaces)
  11. /*
  12.  * Sets the given icon's text to hold the number in "value". (and redraws icon)
  13.  * After the decimal place, up to "decimalplaces" digits will be printed
  14.  * If the number is too big (too many digits), it will be truncated to fit
  15.  * (which may completely destroy the value you wished to represent, or
  16.  * just reduce its accuracy)
  17.  * If unable to set the text (incorrect icon type), it returns quietly
  18.  */
  19. {
  20.   char       text[32], format[16];
  21.  
  22.   sprintf(format, "%%.%df", decimalplaces);
  23.   sprintf(text, format, value);
  24.  
  25.   Icon_SetText(w, i, text);
  26. }
  27.